const AliOSS = require('../utils/aliOSS');
module.exports = app => {
  const {
    config
  } = app;

  const RAM = config.alioss;
  app.oss = {
    maps: {},
    use(key = 'default') {
      if (this.maps[key]) {
        return this.maps[key];
      }
      this.maps[key] = new AliOSS(RAM[key]);
      return this.maps[key];
    },
    close(key) {
      delete this.maps[key];
    },
    closeAll() {
      for (let key in this.maps) {
        delete this.maps[key];
      }
    }
  };
};
